﻿using System;

namespace FxWinSuper.Plugin
{
	[AttributeUsage(AttributeTargets.Assembly)]
	public class WinSupperPluginAttribute : Attribute
	{
		/// <summary>
		/// 插件名
		/// </summary>
		public string Name { get; }

		/// <summary>
		/// 插件作者
		/// </summary>
		public string Author { get; }

		/// <summary>
		/// 插件说明
		/// </summary>
		public string Statement { get; }

		/// <summary>
		/// 插件版本
		/// </summary>
		public string Version { get; }

		/// <summary>
		/// 插件版本号
		/// </summary>
		public int VersionCode { get; }

		/// <summary>
		/// 是否是启动依赖插件
		/// </summary>
		public bool BootStrapPlugin { get; }

		/// <summary>
		/// 插件依赖软件的目标版本
		/// </summary>
		public int DependencySoftwareVersionCode { get; set; }

		public WinSupperPluginAttribute(string name, string author, string statement, string version, int versionCode, bool bootStrapPlugin = false, int dependencySoftwareVersionCode = 0)
		{
			Name = name;
			Author = author;
			Statement = statement;
			Version = version;
			VersionCode = versionCode;
			BootStrapPlugin = bootStrapPlugin;
			DependencySoftwareVersionCode = dependencySoftwareVersionCode;
		}

		internal bool IsSamePlugin(WinSupperPluginAttribute otherPluginAttribute)
		{
			return Name == otherPluginAttribute.Name &&
			       Author == otherPluginAttribute.Author &&
			       VersionCode == otherPluginAttribute.VersionCode &&
			       BootStrapPlugin == otherPluginAttribute.BootStrapPlugin;
		}
	}
}
